package myky.com.doctorapp.presenter;

import io.reactivex.annotations.Nullable;
import io.reactivex.disposables.Disposable;
import myky.com.doctorapp.api.schedulers.SchedulerHelper;
import myky.com.doctorapp.base.BasePresenterIm;
import myky.com.doctorapp.base.SimpleSubscribe;
import myky.com.doctorapp.contract.FeedBackContract;
import myky.com.doctorapp.entity.FeedBackEntity;
import myky.com.doctorapp.model.FeedBackModel;

public class FeedBackPresenter extends BasePresenterIm<FeedBackContract.View> implements FeedBackContract.Presenter {

    FeedBackModel feedBackModel;

    public FeedBackPresenter() {

        feedBackModel = new FeedBackModel();
    }

    @Override
    public void upFeedContent(String customerId, String userName, String phoneModel, String osVersion, String os, String content, String phone, @Nullable String picture) {

        feedBackModel.upFeedContent(customerId, userName, phoneModel, osVersion, os, content, phone, picture)
                .compose(SchedulerHelper.applySchedulers())
                .subscribe(new SimpleSubscribe<FeedBackEntity>() {
                    @Override
                    public void onSubscribe(Disposable d) {
                        addSubscription(d);

                    }

                    @Override
                    protected void onSuccess(FeedBackEntity feedBackEntity) {
                        mView.showDataSuccess(feedBackEntity);

                    }

                    @Override
                    protected void onFailed(String msg) {

                        mView.showDataError(msg);

                    }
                });

    }
}
